<template>
  <div>
    <x-header id="header" :left-options="{backText: ''}">账号管理</x-header>
    <div class="main-header">
      <div class="userInfo">
        <div class="name-con">
          <div class="name">{{detail.name}}</div>
          <img class="name-icon" src="../../../static/img/edit.png" @click="goModify"/>
        </div>
        <div class="phone">{{detail.mobile}}</div>
      </div>
      <div class="permission">
        <group class="group" gutter="1rem">
          <cell class="cell" v-for="(item,index) in permissionList" :key="index" :title="item.title" is-link :link="item.link"  >
            <img slot="icon" width="25" class="cell-icon" :src="item.icon"/>
          </cell>
        </group>
      </div>
      <div class="loginOut">
        <x-button class="loginOut-button" @click.native="loginOut">退出登录</x-button>
      </div>
    </div>
  </div>
</template>

<script>
import { getUserDetail } from '@/api/user'
import { cookie } from 'vux'
export default {
  name: 'user',
  components: {
  },
  data () {
    return {
      permissionList: [
        {
          title: '修改密码',
          icon: require('../../../static/img/password.png'),
          link: 'password'
        },
        {
          title: '银行卡管理',
          icon: require('../../../static/img/bank.png'),
          link: 'bank'
        },
        {
          title: '渠道管理',
          icon: require('../../../static/img/channel.png'),
          link: 'channel'
        },
      ],
      detail: {}
    }
  },
  methods: {
    goModify() {
      this.$router.push('name')
    },
    loginOut() {
      cookie.remove('token')
      cookie.remove('userInfo')
      this.$router.back(-1)
    }
  },
  mounted () {
    getUserDetail(this.globalData.cid).then( data => {
      this.detail = data
    })
  }
}
</script>

<style scoped>
.userInfo {
  padding: 2.5rem 0;
  height: 4.42rem;
  width: 100%;
  background-image: url("../../../static/img/background.png");
  background-size: 100% 100%;
}
.name-con {
  display: flex;
  justify-content: center;
}
.name {
  font-size: 1.71rem;
  line-height: 2.35rem;
  color: #fff;
  padding-right: 1.42rem;
}
.name-icon {
  height:1.15rem;
  width: 1.15rem;
  padding: 0.6rem 0;
}
.phone {
  padding-top: 0.64rem;
  text-align: center;
  color: #fff;
}
.loginOut {
  margin-top: 3rem;
}
.loginOut-button {
  color: #D0021B;
  background: #fff;
  border: none;
  border-radius: 0;
  font-size: 1rem;
  line-height: 3.2rem;
  height: 3.2rem;
  width: 100%;
}
.loginOut-button::after {
  border: none;
}
</style>
